<?php
	require("db.php");
	require("contant.php");	

	$uname = $_POST['name'];//GET方法为URL参数传递  
	$tel = $_POST['tel']; 
	$data = $_POST['data']; 
	
	if(!$uname || !$tel || !$data){
		exit();
	} 
	 
	$sql = "insert into xzq_yuyue (name,tel,data)  values ('$uname','$tel','$data')";
	 
	 $temp =  mysql_query($sql);
	 
	mysql_close(); //关闭MySQL连接
	
	if($temp){
		$result = array("result"=>0,"message"=>"成功录入数据");
		
		     require("smtp.php");
			 date_default_timezone_set ( 'Asia/Shanghai' ); 
			 $subject = date ( "Y-m-d" ) . "龙蟠预约微信表单"; //邮件标题 
			 $content = "姓名".$uname.'电话：'.$tel.'时间：'.$data; //邮件内容 
			 $smtpserver = "smtp.163.com"; //SMTP服务器 
			 $smtpserverport = 25; //SMTP服务器端口 
			 $bcc = "2098740896@qq.com"; //副收件人 
			 $smtpuser = "wapj2095@163.com"; //SMTP服务器的用户帐号 
			 $smtppass = "w7289395"; //SMTP服务器的用户密码 
			 $smtpmailfrom = "wapj2095@163.com"; //SMTP服务器的用户邮箱,邮件发送者 
			 $smtpemailto = "13585169391@163.com"; //邮件接受者 
			 $mailsubject = $subject; //邮件主题 
			 $mailtype = "HTML"; //邮件格式（HTML/TXT）,TXT为文本邮件 
			 $mailbody = $content; //邮件内容 
			 //这里面的一个true是表示使用身份验证,否则不使用身份验证. 
			 $smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//			 $smtp->debug = TRUE;//是否显示发送的调试信息 
			 $issuccess = $smtp->sendmail($smtpemailto, $smtpmailfrom, $mailsubject, $mailbody, $mailtype,$bcc);
			 if ($issuccess =="") { 
			   echo ("发送失败"); 
			 } else { 
			   echo ("发送成功");
			 } 
		
		
		
	}else{
		$result = array("result"=>1,"message"=>"录入数据失败");
	}
	
	
	echo  json_encode($result);
	
	
?>
